if (!NodeList.prototype.forEach) {
    NodeList.prototype.forEach = Array.prototype.forEach;
}
var firstStyle = document.querySelector('link[rel="stylesheet"]');
//文字字号
var fontStyle = document.createElement('style');
fontStyle.innerHTML = ".content { font-size: " + fontSize + "px; } code, pre { font-size: " + (fontSize - 1) + "px; }";
for (var i = 6; i >= 4; i--) {
	fontSize += 2;
	fontStyle.innerHTML += "h" + i + "{ font-size: " + fontSize + "px; }";
}
for (var i = 3; i >= 1; i--) {
	fontSize += 2;
	fontStyle.innerHTML += "h" + i + "{ font-size: " + fontSize + "px; }";
}
document.head.appendChild(fontStyle);
//Tag
var tagEl = document.querySelector('.tags');
tags.split(",").forEach(function(e) {
    var el = document.createElement('a');
    el.href = "#";
    el.innerHTML = e;
    el.setAttribute("data-tag", e);
    el.addEventListener('click', onTagClick);
    tagEl.appendChild(el);
});
function onTagClick() {
    SYBridge.showList("tag", this.getAttribute("data-tag"));
}
//图片点击事件
var imgList = [];
function onImageClick() {
    var index = imgList.indexOf(this.src);
    if (index < 0) {
        index = 0;
    }
    SYBridge.showBigImage(imgList.join('|'), index);
}
document.querySelectorAll("img").forEach(function(e) {
    imgList.push(e.src);
    e.addEventListener('click', onImageClick);
});
//代码高亮
if (document.querySelector('pre') !== null) {
    var s1 = firstStyle.cloneNode(true);
    s1.href = 'https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/styles/shCore.min.css';
    firstStyle.parentElement.insertBefore(s1, firstStyle);
    var s2 = firstStyle.cloneNode(true);
    s2.href = 'https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/styles/shThemeDefault.min.css';
    firstStyle.parentElement.insertBefore(s2, firstStyle);
    var s3 = document.createElement('script');
    s3.src = 'https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shCore.min.js';
    s3.onload = function() {
        var autoload = document.createElement('script');
        autoload.src = 'https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shAutoloader.min.js';
        autoload.onload = function() {
            SyntaxHighlighter.autoloader.apply(null, [
                'bash shell https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shBrushBash.js',
                'cpp c https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shBrushCpp.js',
                'c# c-sharp csharp https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shBrushCSharp.js',
                'css https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shBrushCss.js',
                'java https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shBrushJava.js',
                'jfx javafx https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shBrushJavaFX.js',
                'js jscript javascript https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shBrushJScript.js',
                'php https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shBrushPhp.js',
                'text plain https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shBrushPlain.js',
                'sass scss https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shBrushSass.js',
                'sql https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shBrushSql.js',
                'xml xhtml xslt html https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/scripts/shBrushXml.js'
            ]);
            SyntaxHighlighter.defaults['toolbar'] = false;
            SyntaxHighlighter.all();
        };
        document.body.appendChild(autoload);
    };
    document.body.appendChild(s3);
}